import fetch from "node-fetch";

const url = "http://ajax-base-api-t.itheima.net/api/addbook";
const add = async () => {
  const obj = {
    bookname: "魔法书",
    author: "wstar",
    publisher: "格兰芬多",
  };
  const res = await fetch(url, {
    method: "post",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(obj),
  });
  const json = await res.json();
  console.log(json);
};
add();
